#include<bits/stdc++.h>
using namespace std;
#define int long long
int k;
string s;
string sss;
char c1, c2;
vector<int>ss;//存储所有c2结尾的下标
int ret = 0;
int n;
bool check(int mid, int i)
{
    return ss[mid] - i + 1 >= k;
}
signed main()
{

    // cin >> k >> sss >> c1 >> c2;
    // for (int i = 0; i < (int)sss.size(); i++)
    // {
    //     if (sss[i] != '-') s.push_back(sss[i]);
    // }

    cin>>k>>s>>c1>>c2;
    for (int i = 0; i < (int)s.size(); i++)
    {
        if (s[i] == c2)
        {
            ss.push_back(i);
        }
    }
    for (int i = 0; i < (int)s.size(); i++)
    {
        if (s[i] != c1) continue;
        // for(int j=i+k-1;j<=s.size();j++)
        // {
        //     if(s[j]==c2) ans++;
        // }
        //找到ss[j]里面满足ss[j]-i+1>=k的最小j
        int l = 0, r = ss.size()-1, ans = -1;
        while (l <= r)
        {
            int mid = (r - l) / 2 + l;
            if (check(mid, i))
            {
                ans = mid;
                r = mid - 1;
            }
            else
            {
                l = mid + 1;
            }
        }
        if (ans != -1)
        {
            ret += ss.size() - ans;
        }
    }
    cout << ret << endl;
    return 0;
}